#ifndef JIONOTIFIER_P_H
#define JIONOTIFIER_P_H

// W A R N I N G
// -------------
// This file is not JXQLIB-APIs

#include "jionotifier.h"
#include <JXQCore/JThread>
#include <JXQCore/JSingleton>
#include <JXQCore/JMutex>
#include <JXQCore/JDebug>
#include <unordered_map>
#include <atomic>

namespace JXQ
{

typedef JIONotifier::Type  Type;

class J_DECL_HIDDEN ListenThread : public JThread
{
	J_PERMANENT_SINGLETON(ListenThread)

public:
	void addDescriptor(JIONotifier *q_ptr, int descriptor, Type type);
	void deleteDescriptor(int descriptor);

protected:
	void run() override;
};

class J_DECL_HIDDEN JIONotifierPrivate
{
public:
	JIONotifierPrivate(JIONotifier *q_ptr, int descriptor, Type type);
	~JIONotifierPrivate();

public:
	int m_descriptor;
	Type m_type;
	std::atomic_bool m_closeOnDelete {false};

private:
	void close();
};

} //namespace JXQ


#endif //JIONOTIFIER_P_H
